package com.xiaochong.tir.trades.rabbit;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * Created by org on 2018/6/15.
 * 币安队列绑定
 */
@Configuration
@Component
public class HadaxQueenConfig {
    /**
     * 配置消息交换机
     * 针对消费者配置
     FanoutExchange: 将消息分发到所有的绑定队列，无routingkey的概念
     HeadersExchange ：通过添加属性key-value匹配
     DirectExchange:按照routingkey分发到指定队列
     TopicExchange:多关键字匹配
     */
    @Bean
    public DirectExchange HadaxNodeAPIExchange() {
        return new DirectExchange(ExchangeQueue.Exchange.EX_NODE_API_MQ, true, false);
    }
    @Bean
    public Queue queueTradesHadaxBtcAction(){
        return new Queue(HadaxMqQueue.QUEUE_TRADES_HADAX_BTC, true);
    }
    @Bean
    public Binding bindingTradesHadaxBtcAction(){
        return BindingBuilder.bind(queueTradesHadaxBtcAction()).to(HadaxNodeAPIExchange()).with(HadaxMqQueue.QUEUE_TRADES_HADAX_BTC);
    }

    @Bean
    public Queue queueTradesHadaxEthAction(){
        return new Queue(HadaxMqQueue.QUEUE_TRADES_HADAX_ETH, true);
    }
    @Bean
    public Binding bindingTradesHadaxEthAction(){
        return BindingBuilder.bind(queueTradesHadaxEthAction()).to(HadaxNodeAPIExchange()).with(HadaxMqQueue.QUEUE_TRADES_HADAX_ETH);
    }

    @Bean
    public Queue queueTradesHadaxHtAction(){
        return new Queue(HadaxMqQueue.QUEUE_TRADES_HADAX_HT, true);
    }
    @Bean
    public Binding bindingTradesHadaxHtAction(){
        return BindingBuilder.bind(queueTradesHadaxHtAction()).to(HadaxNodeAPIExchange()).with(HadaxMqQueue.QUEUE_TRADES_HADAX_HT);
    }
}
